# Makefile
# Author : Edouard ROGE

CC		= g++
AR		= ar -rcs
CFLAGS		= -fPIC -Wall
LDFLAGS		= -shared
LIBS		= -L/usr/local/lib -lpthread -L../../lib -lcore
INCLUDES	= -I. -I../../include

PROJECT=Math
NAME=libmath
SRC_DIR=./
OBJ_DIR=../../obj/$(PROJECT)
LIB_DIR=../../lib
INC_DIR=../../include/$(PROJECT)

SRC_FILES=	2D/Point2D.cpp \
		3D/Point3D.cpp \
		2D/Vector2D.cpp \
		3D/Vector3D.cpp \
		3D/Matrix.cpp \
		3D/Quaternion.cpp \
		3D/Ray.cpp \
		Color/Color.cpp \
			
HDR_FILES=$(addprefix $(SRC_DIR)/, $(SRC_FILES:.cpp=.h))
OBJ_FILES=$(addprefix $(OBJ_DIR)/, $(SRC_FILES:.cpp=.o))

TARGET=$(LIB_DIR)/$(NAME).so

release: CFLAGS += -O3
release:$(TARGET)
debug: CFLAGS += -DDEBUG -g
debug:$(TARGET)
all:$(TARGET)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
	@echo -n "Compiling `basename $<` : "
	@$(CC) -c $< $(CFLAGS) $(INCLUDES) -o $@
	@cp $(<:.cpp=.h) $(INC_DIR)/$(dir $<)
	@echo "OK"

$(TARGET):$(OBJ_FILES)
	@echo -n "Creating `basename $@` : "
	@$(CC) $(LDFLAGS) -o $(TARGET) $(OBJ_FILES)
	@echo "OK"

clean:
	@echo -n "$(PROJECT) : Deleting .o and library: "
	@rm -f $(OBJ_FILES)
	@rm -f $(TARGET)
	@echo "OK"
	
